home *** CD-ROM | disk | FTP | other *** search
/ Komputer for Alle 2003 #3 / K-CD-3-2003.ISO / WinXP Service Pack 1 / xpsp1_sv_x86.exe / ipp_0004.as_ / ipp_0004.asp
Encoding:
Text File  |  2002-08-01  |  9.2 KB  |  307 lines

  1. ∩╗┐<%@ CODEPAGE=65001 %>
  2. <%
  3. ' Replace the above line with your localized code page number
  4. '------------------------------------------------------------
  5. '
  6. ' Microsoft Internet Printing Project
  7. '
  8. ' Copyright (c) Microsoft Corporation. All rights reserved.
  9. '
  10. ' Entry page for printer view.
  11. '
  12. '------------------------------------------------------------
  13.     option explicit
  14. %>
  15. <!-- #include file = "ipp_util.inc" -->
  16. <%
  17.  
  18. Const PRINTER_FOLDER        = "pfld"
  19. Const L_PrinterAction_Text  = "Skrivar├Ñtg├ñrd"
  20. Const L_JobAction_Text      = "Utskrifts├Ñtg├ñrd"
  21. Const L_CancelAction_Text   = "Dokumentet kunde inte avbrytas. Det har antagligen redan skrivits ut eller avbrutits av en annan anv├ñndare."
  22. Const L_OpenHelperName_Text = "├ûppna hj├ñlp: %1"
  23. Const L_OpenHelper_Text     = "├ûppna hj├ñlp"
  24.  
  25. Dim strEncodedPrinter, strURLPrinter, strASP1, strSNMP, strIPAddress, strCommunity
  26. Dim strDevice, strPortname, strModel, bEnableConnect
  27.  
  28. Randomize
  29.  
  30. Sub Redirect (strView, strStart, strEnd)
  31.     Dim strURL
  32.  
  33.     strURL = "ipp_0004.asp?eprinter=" & strEncodedPrinter & VIEW_EQUALS & strView & ATPAGE & CStr(Int(Rnd*10000))
  34.     If strView = "q" Then
  35.         If (strStart <> "" And strEnd <> "") Then
  36.             strURL = strURL & "&startid=" & strStart & "&endid=" & strEnd
  37.         End If
  38.     End If
  39.  
  40.     Response.Redirect (strURL)
  41.  
  42. End Sub
  43.  
  44. Sub SetPrinterVariables (objHelper, strPrinter)
  45.  
  46.     On Error Resume Next
  47.     Dim str
  48.  
  49.     strUrlPrinter = Server.URLEncode(strPrinter)
  50.  
  51.     str = objHelper.ASPPage(1)
  52.     If Err Then
  53.         strASP1 = ""
  54.     Else
  55.         strASP1 = str
  56.     End If
  57.  
  58.     If objHelper.IsTCPMonSupported Then
  59.         bSNMP = objHelper.SNMPSupported
  60.         strSNMP = CStr( bSNMP )
  61.         strIPAddress = CStr( objHelper.IPAddress )
  62.         If bSNMP Then
  63.             strCommunity = objHelper.Community
  64.             strDevice = CStr( objHelper.SNMPdevice )
  65.         End If
  66.     Else
  67.         strSNMP      = ""
  68.         strIPAddress = ""
  69.         strCommunity = ""
  70.         strDevice    = ""
  71.     End If
  72.  
  73.     session(LOCAL_SERVER)  = request.ServerVariables("SERVER_NAME")
  74.     session(DHTML_ENABLED) = bDHTMLSupported
  75.     strPortname = OleCvt.EncodeUnicodeName( objHelper.PortName )
  76.     session(DEFAULT_PAGE) = "/printers/Page1.asp"
  77.     strModel = OleCvt.EncodeUnicodeName( objHelper.DriverName )
  78.  
  79.     If objHelper.DriverName = FAXDRIVER Then
  80.        bEnableConnect = FALSE
  81.     Else
  82.        bEnableConnect = TRUE
  83.     end If
  84.  
  85. End Sub
  86.  
  87. Function SetView (strClient, strPrinter, strView, strStart, strEnd)
  88.     dim bDeviceStatus
  89.  
  90.     bDeviceStatus = False
  91.  
  92.     if Session("StartInstall") = 1 Then
  93.     strView = "p"
  94.     strInitial = "ipp_0010.asp?eprinter=" & Request ("eprinter")
  95.  
  96.     Else    
  97.         if strClient = PRINTER_FOLDER Then
  98.             If strASP1 <> "" Then
  99.                 strView = "q"
  100.                 strInitial = strASP1
  101.             Else
  102.                 strView = "p"
  103.                 strInitial = PROPERTY_VIEW
  104.             End If
  105.         Else
  106.             if strView = "" Then strView = "d"
  107.  
  108.             Select Case strView
  109.             Case "p"
  110.                 strInitial = PROPERTY_VIEW
  111.             Case "q"
  112.                 strInitial = QUEUE_VIEW
  113.             Case "d"
  114.                 strInitial = strASP1
  115.                 If strInitial = "" Then
  116.                     strView = "q"
  117.                     strInitial = QUEUE_VIEW
  118.                 End If
  119.             case Else
  120.                 strView = "q"
  121.                 strInitial = QUEUE_VIEW
  122.             End Select
  123.         End If
  124.  
  125.         if strInitial = strASP1 then
  126.            bDeviceStatus = True
  127.         end if
  128.  
  129.         strInitial = strInitial & "?eprinter=" & strEncodedPrinter & VIEW_EQUALS & strView
  130.  
  131.         if bDeviceStatus then
  132.             strInitial = strInitial & ATPRINTER   & strEncodedPrinter & ATURLPRINTER & strURLPrinter &_
  133.                                       ATSNMP      & strSNMP           & ATIPADDRESS  & strIPAddress  &_
  134.                                       ATCOMMUNITY & strCommunity      & ATDEVICE     & strDevice     &_
  135.                                       ATPORTNAME  & strPortname       & ATMODEL      & strModel
  136.         End If
  137.  
  138.         strInitial = strInitial & ATASP1 & strASP1
  139.         strInitial = strInitial & ATPAGE & CStr(Int(Rnd*10000))
  140.  
  141.         If strStart <> "" And strEnd <> "" Then
  142.             strInitial = strInitial & "&startid=" & strStart & "&endid=" & strEnd
  143.         End If
  144.     End If
  145.  
  146.     SetView = strView
  147.  
  148. End Function
  149.  
  150. Function FindJob (objJobs, strJobid, objJob)
  151.     FindJob = FALSE
  152.     If strJobid = "" Then Exit Function
  153.  
  154.     For Each objJob In objJobs
  155.         If objJob.Name = strJobid Then
  156.             FindJob = True
  157.             Exit For
  158.         End If
  159.     Next
  160.  
  161. End Function
  162.  
  163. Sub DoAction (strAction, objQueue, strJobid, strStart, strEnd)
  164.  
  165.     On Error Resume Next
  166.     Err.Clear
  167.     Dim objJobs, objJob
  168.  
  169.     Select Case strAction
  170.     Case "pause"
  171.         objQueue.Pause
  172.         If Err Then Call ErrorHandler (L_PrinterAction_Text)
  173.         Redirect "p", strStart, strEnd
  174.  
  175.     Case "resume"
  176.         objQueue.Resume
  177.         If Err Then Call ErrorHandler (L_PrinterAction_Text)
  178.         Redirect "p", strStart, strEnd
  179.  
  180.     Case "purge"
  181.         objQueue.Purge
  182.         If Err Then Call ErrorHandler (L_PrinterAction_Text)
  183.         Redirect "q", strStart, strEnd
  184.  
  185.     Case "canceljob"
  186.         Set objJobs = objQueue.PrintJobs
  187.         If FindJob (objJobs, strJobid, objJob) Then
  188.             objJobs.Remove CStr(strJobid)
  189.     Else
  190.             Call ErrorHandler(L_CancelAction_Text)
  191.     End if
  192.  
  193.         If Err Then Call ErrorHandler (L_JobAction_Text)
  194.         Redirect "q", strStart, strEnd
  195.  
  196.     Case "resumejob"
  197.         Set objJobs = objQueue.PrintJobs
  198.         If FindJob (objJobs, strJobid, objJob) Then objJob.resume
  199.         If Err Then Call ErrorHandler (L_JobAction_Text)
  200.         Redirect "q", strStart, strEnd
  201.  
  202.     Case "pausejob"
  203.         Set objJobs = objQueue.PrintJobs
  204.         If FindJob (objJobs, strJobid, objJob) Then objJob.pause
  205.         If Err Then Call ErrorHandler (L_JobAction_Text)
  206.         Redirect "q", strStart, strEnd
  207.     End Select
  208. End Sub
  209.  
  210.     Dim strPrinter, objHelper, str, bSNMP, strInitial, strView, strClient, strAction
  211.     Dim strComputer
  212.     On Error Resume Next
  213.     Err.Clear
  214.  
  215.     Rem
  216.     Rem Parse the input variable
  217.     Rem
  218.  
  219.     strEncodedPrinter = strCleanRequest ("eprinter")
  220.     if strEncodedPrinter = "" Then
  221.         Response.Redirect ("ipp_0001.asp")
  222.     Else
  223.         Rem
  224.         Rem Decode the printer name
  225.         Rem
  226.  
  227.         strPrinter = OleCvt.DecodeUnicodeName (strEncodedPrinter)
  228.  
  229.     End If
  230.  
  231.     Set objHelper = Server.CreateObject(PROGID_HELPER)
  232.     If Err Then Call ErrorHandler(ERR_CREATE_HELPER_OBJ)
  233.  
  234.     strComputer = request.ServerVariables("SERVER_NAME")
  235.     If strComputer = "localhost" Or strComputer = "127.0.0.1" or Not objHelper.IsCluster Then
  236.         strComputer = objHelper.ComputerName
  237.     End If
  238.  
  239.     session(COMPUTER) = strComputer
  240.  
  241.     objHelper.open "\\" & strComputer & "\" & strPrinter
  242.     if Err Then
  243.         Call ErrorHandler(RepString1(L_OpenHelperName_Text, strPrinter) )
  244.     End If
  245.     strPrinter = objHelper.ShareName
  246.  
  247.     strEncodedPrinter = OleCvt.EncodeUnicodeName (strPrinter)
  248.  
  249.     Dim objQueue
  250.     Set objQueue = GetObject("WinNT://" & strComputer & "/" & strPrinter & ",PrintQueue")
  251.     If Err Then
  252.         Err.Number = &H80070709
  253.         Call ErrorHandler(L_OpenHelper_Text)
  254.     End If
  255.  
  256.     strAction = Request("action")
  257.     If strAction <> "" Then
  258.         Call DoAction (strAction, objQueue, Request ("jobid"), Request ("StartId"), Request ("EndId"))
  259.     End If
  260.  
  261.     strClient = Request("Client")
  262.  
  263.  
  264.     Call SetPrinterVariables (objHelper, strPrinter)
  265.     objHelper.Close
  266.  
  267.     strView = SetView (strClient, strPrinter, Request ("View"), Request ("StartId"), Request ("EndId"))
  268.  
  269.     Response.Expires = 0
  270.  
  271. %>
  272. <html>
  273.  
  274. <head>
  275. <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
  276. <%=SetCodePage%>
  277. <%
  278.     Dim strTitle
  279.     Dim strLeftPaneUrl
  280.  
  281.     const L_Title_Text = "<title>%1 p├Ñ %2</title>"
  282.     const L_FramesWarning_Text = "Den h├ñr webbsidan anv├ñnder ramar, men detta st├╢ds inte av din webbl├ñsare."
  283.  
  284.     strTitle = RepString2(L_Title_Text, strCleanString( GetFriendlyName (objQueue.PrinterName, session(COMPUTER))), session(LOCAL_SERVER) )
  285.     strLeftPaneUrl = "ipp_0005.asp?eprinter=" & strEncodedPrinter & VIEW_EQUALS & strView & ATCONNECT & bEnableConnect & ATURLPRINTER & strURLPrinter
  286.     strLeftPaneUrl = strLeftPaneUrl & ATASP1 & strASP1 & ATPAGE & CStr(Int(Rnd*10000))
  287. %>
  288. <% =Write (strTitle) %>
  289. </head>
  290.  
  291. <frameset frameborder="0" framespacing="10" cols="180,*">
  292.  
  293.      <frame src="<%=strLeftPaneUrl%>" name="contents" scrolling="auto" noresize>
  294.      <frameset frameborder="0" framespacing="0" rows="100,*">
  295.         <frame scrolling="auto" src="ipp_0002.asp?eprinter=<%=strEncodedPrinter%>&page=<%=CStr(Int(Rnd*10000))%>" frameborder="0" name="banner" scrolling="no" noresize>
  296.         <frame src="<% =strinitial%>" frameborder="0" name="main" scrolling="auto">
  297.      </frameset>
  298.  
  299. <noframes>
  300.     <body>
  301.     <p><%=Write(L_FramesWarning_Text)%></p>
  302.     </body>
  303.     </noframes>
  304. </frameset>
  305.  
  306. </html>
  307.